load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "pgwire",
    srcs = [
        "auth.go",
        "auth_behaviors.go",
        "auth_methods.go",
        "authenticator.go",
        "command_result.go",
        "conn.go",
        "hba_conf.go",
        "ident_map_conf.go",
        "pre_serve.go",
        "pre_serve_options.go",
        "role_mapper.go",
        "server.go",
        "types.go",
        "write_buffer.go",
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/sql/pgwire",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/base",
        "//pkg/clusterversion",
        "//pkg/col/coldata",
        "//pkg/jobs",
        "//pkg/roachpb",
        "//pkg/security",
        "//pkg/security/password",
        "//pkg/security/sessionrevival",
        "//pkg/security/username",
        "//pkg/server/pgurl",
        "//pkg/server/serverpb",
        "//pkg/server/telemetry",
        "//pkg/settings",
        "//pkg/settings/cluster",
        "//pkg/settings/rulebasedscanner",
        "//pkg/sql",
        "//pkg/sql/catalog/catalogkeys",
        "//pkg/sql/catalog/colinfo",
        "//pkg/sql/clusterunique",
        "//pkg/sql/lex",
        "//pkg/sql/parser",
        "//pkg/sql/parser/statements",
        "//pkg/sql/pgrepl/pgreplparser",
        "//pkg/sql/pgrepl/pgrepltree",
        "//pkg/sql/pgwire/hba",
        "//pkg/sql/pgwire/identmap",
        "//pkg/sql/pgwire/pgcode",
        "//pkg/sql/pgwire/pgerror",
        "//pkg/sql/pgwire/pgnotice",
        "//pkg/sql/pgwire/pgwirebase",
        "//pkg/sql/pgwire/pgwirecancel",
        "//pkg/sql/sem/catconstants",
        "//pkg/sql/sem/tree",
        "//pkg/sql/sessiondatapb",
        "//pkg/sql/sqltelemetry",
        "//pkg/sql/types",
        "//pkg/util",
        "//pkg/util/ctxlog",
        "//pkg/util/duration",
        "//pkg/util/envutil",
        "//pkg/util/errorutil/unimplemented",
        "//pkg/util/humanizeutil",
        "//pkg/util/ipaddr",
        "//pkg/util/json",
        "//pkg/util/log",
        "//pkg/util/log/eventpb",
        "//pkg/util/log/logpb",
        "//pkg/util/log/severity",
        "//pkg/util/metric",
        "//pkg/util/metric/aggmetric",
        "//pkg/util/mon",
        "//pkg/util/netutil",
        "//pkg/util/ring",
        "//pkg/util/stop",
        "//pkg/util/syncutil",
        "//pkg/util/timeofday",
        "//pkg/util/timeutil",
        "//pkg/util/timeutil/pgdate",
        "//pkg/util/tracing",
        "//pkg/util/tsearch",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_apd_v3//:apd",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_logtags//:logtags",
        "@com_github_cockroachdb_redact//:redact",
        "@com_github_go_ldap_ldap_v3//:ldap",
        "@com_github_lib_pq//oid",
        "@com_github_prometheus_client_model//go",
        "@com_github_xdg_go_scram//:scram",
        "@io_opentelemetry_go_otel//attribute",
        "@org_golang_google_grpc//codes",
        "@org_golang_google_grpc//status",
    ],
)

go_test(
    name = "pgwire_test",
    size = "medium",
    srcs = [
        "auth_test.go",
        "authpipe_test.go",
        "command_result_test.go",
        "conn_test.go",
        "encoding_test.go",
        "helpers_test.go",
        "main_test.go",
        "pgtest_test.go",
        "pgwire_test.go",
        "types_test.go",
    ],
    data = glob(["testdata/**"]),
    embed = [":pgwire"],
    exec_properties = select({
        "//build/toolchains:is_heavy": {"test.Pool": "heavy"},
        "//conditions:default": {"test.Pool": "default"},
    }),
    shard_count = 16,
    deps = [
        "//pkg/base",
        "//pkg/ccl",
        "//pkg/cloud/impl:cloudimpl",
        "//pkg/col/coldata",
        "//pkg/col/coldataext",
        "//pkg/col/coldatatestutils",
        "//pkg/security/securityassets",
        "//pkg/security/securitytest",
        "//pkg/security/username",
        "//pkg/server",
        "//pkg/server/telemetry",
        "//pkg/settings/cluster",
        "//pkg/sql",
        "//pkg/sql/catalog/colinfo",
        "//pkg/sql/clusterunique",
        "//pkg/sql/colconv",
        "//pkg/sql/isql",
        "//pkg/sql/lex",
        "//pkg/sql/parser",
        "//pkg/sql/pgwire/hba",
        "//pkg/sql/pgwire/identmap",
        "//pkg/sql/pgwire/pgcode",
        "//pkg/sql/pgwire/pgerror",
        "//pkg/sql/pgwire/pgwirebase",
        "//pkg/sql/pgwire/pgwirecancel",
        "//pkg/sql/randgen",
        "//pkg/sql/sem/eval",
        "//pkg/sql/sem/tree",
        "//pkg/sql/sessiondata",
        "//pkg/sql/sessiondatapb",
        "//pkg/sql/types",
        "//pkg/testutils",
        "//pkg/testutils/datapathutils",
        "//pkg/testutils/pgtest",
        "//pkg/testutils/serverutils",
        "//pkg/testutils/skip",
        "//pkg/testutils/sqlutils",
        "//pkg/testutils/testcluster",
        "//pkg/util",
        "//pkg/util/cidr",
        "//pkg/util/ctxgroup",
        "//pkg/util/duration",
        "//pkg/util/leaktest",
        "//pkg/util/log",
        "//pkg/util/log/channel",
        "//pkg/util/log/logconfig",
        "//pkg/util/metric",
        "//pkg/util/metric/aggmetric",
        "//pkg/util/mon",
        "//pkg/util/randutil",
        "//pkg/util/timeutil",
        "//pkg/util/timeutil/pgdate",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_apd_v3//:apd",
        "@com_github_cockroachdb_datadriven//:datadriven",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_errors//stdstrings",
        "@com_github_cockroachdb_redact//:redact",
        "@com_github_jackc_pgconn//:pgconn",
        "@com_github_jackc_pgproto3_v2//:pgproto3",
        "@com_github_jackc_pgx_v4//:pgx",
        "@com_github_jackc_pgx_v5//:pgx",
        "@com_github_lib_pq//:pq",
        "@com_github_lib_pq//oid",
        "@com_github_stretchr_testify//require",
        "@org_golang_x_sync//errgroup",
    ],
)
